package com.nyist.test.web;

import com.nyist.test.entity.User;
import com.nyist.test.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService iUserService;

    @ResponseBody
    @RequestMapping(value ="/list", method = RequestMethod.GET)
    public List<User> findUserList()
    {
        return iUserService.findList();
    }

    @RequestMapping(value = "", method = RequestMethod.POST)
    public String postAccount(User user) {
        int temp= iUserService.add(user);
        if(temp==1) {
            return "success";
        }else {
            return "fail";
        }

    }

}
